﻿<!DOCTYPE>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath(); 
	//获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量 
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	pageContext.setAttribute("basePath",basePath); 
	pageContext.setAttribute("path",path); 
%>    
<html>

<head>
<title>注册</title>
<meta content="注册页面" name="description">
<meta content="注册页面关键字" name="keywords">
<link rel="stylesheet" type="text/css" href="${basePath}css/style.css"/>
<script type="text/javascript" src="${basePath}js/jquery-3.2.1.js"></script>
</head>

<body id="login_bg">
	<div class="login_wrapper">
		<div class="login_box">
        	<form id="loginForm" method="post">
        		<ul class="register_radio clearfix">
		            <li>找工作<input type="radio" value="0" name="type" /></li>
		            <li>招人<input type="radio" value="1" name="type" /></li>
		        </ul> 
            	<input type="text" id="email" name="email" tabindex="1" placeholder="请输入常用邮箱地址" />
                <span class="error" style="display:none;" id="beError"></span>
                <input type="password" id="password" name="password" tabindex="2" placeholder="请输入密码" />
                <!-- <input type="submit" id="submitLogin" value="注 &nbsp; &nbsp; 册" /> -->
                <a style="color:#fff;" href="javascript:check();" class="submitLogin" title="注 &nbsp; &nbsp; 册"/>注 &nbsp; &nbsp; 册</a>
            </form>
        </div>
    </div>
    
    <div >
        	<a href="${basePath}common/login" id="aurl">a</a>
    </div>
    
    <script type="text/javascript">
    
    $(document).ready(function() {
    	$('.register_radio li input').click(function(e){
    		$(this).parent('li').addClass('current').append('<em></em>').siblings().removeClass('current').find('em').remove();
    	});
    	
    	$('#email').focus(function(){
    		$('#beError').hide();
    	});
    });
    function check(){
    		var type =$('input[type="radio"]:checked').val();
    		var email =$('#email').val();
    		var password =$('#password').val();
    		if(type==null || type==undefined){alert("请选择注册目的");return ;}
    		if(email == null || email == undefined){alert("请输入邮箱");return ;}
    		if(password == null || email == undefined){alert("请输入密码");return ;}
    		$.ajax({
    			type:'POST',
            	data: {email:email,password:password,type:type},
            	url:'${basePath}user/register',
            	dataType:'json',
            	success:function(result){
            		console.log("success");
            		var model = result.model;
                	if(model.code==0){
                		alert("注册成功");
                		window.location.href='${basePath}common/login';			            		
                	}else{
                		alert(model.msg);
                		console.log(window.location.href);
                	}
            	},
            	error:function(result){
            		
            	}
    		});
    		
    }
    </script>
</body>
</html>
